home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Programming / ace_gpl_release / src / lib / asm / locate.s < prev    next >
Encoding:
Text File  |  1998-10-04  |  3.1 KB  |  153 lines

  1. ;
  2. ; locate.s -- an ACE linked library module: LOCATE.
  3. ; Copyright (C) 1998 David Benn
  4. ; This program is free software; you can redistribute it and/or
  5. ; modify it under the terms of the GNU General Public License
  6. ; as published by the Free Software Foundation; either version 2
  7. ; of the License, or (at your option) any later version.
  8. ;
  9. ; This program is distributed in the hope that it will be useful,
  10. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. ; GNU General Public License for more details.
  13. ;
  14. ; You should have received a copy of the GNU General Public License
  15. ; along with this program; if not, write to the Free Software
  16. ; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  17. ;
  18. ; Author: David J Benn
  19. ;   Date: 19th March 1994
  20. ;
  21. ; registers d0-d6 and a0-a3 are modified by some of the following. BEWARE!
  22. ;
  23. ; a4,a5 are used by link/unlk.
  24. ; a6 is library base holder.
  25. ; a7 is stack pointer. 
  26. ; d7 is used for array index calculations.
  27. ;
  28.  
  29. ; * CONSTANTS *
  30. Font        equ 52
  31. tf_YSize    equ 20
  32. tf_XSize    equ 24
  33.  
  34.     xdef    _locate
  35.  
  36.     ; external references    
  37.     xref    _IntuiMode
  38.     xref    _RPort
  39.     xref    _GfxBase
  40.     xref    _LVOMove
  41.     xref    _DOSBase
  42.     xref    _LVOWrite
  43.     xref    _stdout
  44.     xref    _longtemp
  45.     xref    _locatestr
  46.  
  47.     SECTION locate_code,CODE
  48.  
  49. ;
  50. ; LOCATE - places the cursor at LINE,COLUMN in the current window or screen.
  51. ;        d0=LINE; d1=COLUMN
  52. ;    
  53. _locate:
  54.     move.l    a6,-(sp)    ; store a6 (LOCATE called within C function)
  55.  
  56.     ; is line value too low?
  57.     cmpi.w    #1,d0
  58.     bge.s    _checklinehi
  59.     move.w    #1,d0
  60.  
  61. _checklinehi:
  62.     ; is line value too high?
  63.     cmpi.w    #56,d0            ; arbitrarily high (for height of 400)
  64.     ble.s    _checkcollo
  65.     move.w    #56,d0
  66.  
  67. _checkcollo:
  68.     ; is column value too low?
  69.     cmpi.w    #1,d1
  70.     bge.s    _checkcolhi
  71.     move.w    #1,d1
  72.     
  73. _checkcolhi:    
  74.     ; is column value too high?
  75.     cmpi.w    #80,d1            
  76.     ble.s    _changelocn
  77.     move.w    #80,d1
  78.  
  79. _changelocn:
  80.     ; are we in screen or window mode?
  81.     cmp.b    #0,_IntuiMode
  82.     beq.s    _changewindowlocn
  83.  
  84.     ; change screen location for PRINTS (and graphics commands).
  85.     ; (first gets font height and width)
  86.     movea.l    _RPort,a0
  87.     movea.l    Font(a0),a0
  88.     move.w    tf_YSize(a0),d2    ; height
  89.     move.w    tf_XSize(a0),d3    ; width
  90.  
  91.     mulu    d2,d0    
  92.      subi.w    #2,d0    ; y=LINE*height - 2
  93.  
  94.     subi.w    #1,d1
  95.     mulu    d3,d1    ; x=(COLUMN-1)*width
  96.  
  97.     ; swap d0 and d1
  98.     move.w    d0,d2
  99.     move.w    d1,d0
  100.     move.w    d2,d1
  101.  
  102.     ; move to new x,y
  103.     movea.l    _RPort,a1
  104.     movea.l    _GfxBase,a6
  105.     jsr    _LVOMove(a6)
  106.  
  107.     move.l    (sp)+,a6
  108.  
  109.     rts
  110.             
  111. _changewindowlocn:
  112.     ; convert LINE value to 2 ASCII digits and place in locate string
  113.     ext.l    d0
  114.     divu    #10,d0
  115.     move.l    d0,_longtemp
  116.     lea    _locatestr,a0
  117.     add.w    #48,d0
  118.     and.b    #$ff,d0
  119.     move.b    d0,1(a0)
  120.     move.l    _longtemp,d0
  121.     swap    d0
  122.     add.w    #48,d0
  123.     and.b    #$ff,d0
  124.     move.b    d0,2(a0)
  125.  
  126.     ; convert COLUMN value to 2 ASCII digits and place in locate string
  127.     ext.l    d1
  128.     divu    #10,d1
  129.     move.l    d1,_longtemp
  130.     lea    _locatestr,a0
  131.     add.w    #48,d1
  132.     and.b    #$ff,d1
  133.     move.b    d1,4(a0)
  134.     move.l    _longtemp,d1
  135.     swap    d1
  136.     add.w    #48,d1
  137.     and.b    #$ff,d1
  138.     move.b    d1,5(a0)
  139.  
  140.     ; change cursor location
  141.     move.l    _DOSBase,a6
  142.     move.l    _stdout,d1
  143.     move.l    #_locatestr,d2
  144.     move.l    #7,d3
  145.     jsr    _LVOWrite(a6)
  146.     
  147.     move.l    (sp)+,a6
  148.     
  149.     rts
  150.  
  151.     END
  152.